/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Client;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * Created with IntelliJ IDEA.
 * User: Anastasia
 * Date: 16.12.14
 * Time: 12:38
 * To change this template use File | Settings | File Templates.
 */
public class AddDepartment  extends JFrame implements ActionListener {



    private JLabel label;
    private JPanel panel;
    private JTextField name ;

    private JButton withoutChief;
    private JButton chieffromList;
    private JButton newEmployee;


    public void actionPerformed(ActionEvent arg0)
    {
        try{
            InetAddress addr = InetAddress.getByName(null);

            Socket socket = new Socket(addr, 8080);

            //         BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            PrintWriter outer = new PrintWriter(new BufferedWriter(
                    new OutputStreamWriter(socket.getOutputStream())), true);
            outer.println(3);  //это будет команда


            socket.close();  }

        catch(UnknownHostException e)
        {

        }

        catch(IOException e)
        {

        }





        this.setVisible(true);
        setBounds(600,600,700,700);
        panel = new JPanel();
        panel.setLayout(null);




        label = new JLabel("Название отдела");
       label.setBounds(5,20,80,30);
        panel.add(label) ;

        name = new JTextField();
        name.setBounds(100, 20, 200, 30);

        panel.add(name);



        withoutChief = new JButton("Без начальника");
       withoutChief.setBounds(5,100,200,30);
        panel.add(withoutChief);


        chieffromList = new JButton("Из списка");
       chieffromList.setBounds(215,100,200,30);
        panel.add(chieffromList);


       newEmployee = new JButton("Новый начальник");
        newEmployee.setBounds(430,100,200,30);
        panel.add(newEmployee);

       newEmployee.addActionListener(new AddChief());

        panel.validate();



        this.add(panel);
        setPreferredSize(new Dimension(500, 800));



    }
}
